'''
Setup common for tests.

'''
import os

def clean_up():
    """
    Cleans up tmp directory from any left-overs from previous runs.
    """
    projdir = os.path.split(os.path.dirname(__file__))[0]
    tmpdir = os.path.join(projdir, "tmp")
    if (not os.path.exists(tmpdir)):
        os.mkdir(tmpdir)
    olddir = os.path.join(tmpdir, "old")
    if (not os.path.exists(olddir)):
        os.mkdir(olddir)
    for the_file in os.listdir(tmpdir):
        if the_file.endswith(".pckl"):
            os.remove(os.path.join(tmpdir, the_file))
    return olddir, tmpdir, projdir
